package cn.wolfcode.p2p.business.controller;

import cn.wolfcode.p2p.base.query.RechargeOfflineQueryObject;
import cn.wolfcode.p2p.business.service.IPlatformBankInfoService;
import cn.wolfcode.p2p.business.service.IRechargeOfflineService;
import cn.wolfcode.p2p.util.JSONResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 线下充值审核
 */
@Controller
public class RechargeOfflineAuditController {

    @Autowired
    private IRechargeOfflineService rechargeOfflineService;

    @Autowired
    private IPlatformBankInfoService platformBankInfoService;

    /**
     * 线下充值审核页面
     * @return
     */
    @RequestMapping("rechargeOffline")
    public String moneyWithdraw(@ModelAttribute("qo")RechargeOfflineQueryObject qo, Model model){
        model.addAttribute("banks",platformBankInfoService.listPlatformBankInfo());
        model.addAttribute("pageResult",rechargeOfflineService.queryRechargeList(qo));
        return "rechargeoffline/list";
    }

    /**
     * 线下充值审核
     * @param id 充值对象的id
     * @param remark 审核备注
     * @param state 审核的结果
     * @return json数据
     */
    @RequestMapping("rechargeOffline_audit")
    @ResponseBody
    public Object rechargeOfflineAudit(Long id,String remark,Integer state){
        rechargeOfflineService.rechargeOfflineAudit(id,remark,state);
        return JSONResultUtil.jsonResult();
    }
}
